package com.heer.gymnasium.module.common.beans;

import com.heer.gymnasium.base.BaseBean;
import com.heer.gymnasium.module.store.beans.CourseBean;
import com.heer.gymnasium.module.store.beans.CourseResponseBean;
import com.heer.gymnasium.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 时间段
 * Created by zy on 2018/1/25.
 */

public class PeriodBean extends BaseBean {
    private String id;
    private String date;
    private String timeInDate;
    private String state;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTimeInDate() {
        return timeInDate;
    }

    public void setTimeInDate(String timeInDate) {
        this.timeInDate = timeInDate;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public static List<PeriodBean> dataChange(CourseResponseBean data) {
        List<PeriodBean> courseBeanList = new ArrayList<>();
        for (CourseResponseBean.Item item : data.getList()) {
            PeriodBean bean = new PeriodBean();
            bean.setId(item.getId());
            bean.setState(item.getStatus());
            bean.setDate(StringUtils.getPhpDateFormat(item.getCourse_date(), new SimpleDateFormat("MM月dd日")));
            bean.setTimeInDate(StringUtils.getPhpDateFormat(item.getStart_time(), new SimpleDateFormat("HH:mm")) + "-"
                    + StringUtils.getPhpDateFormat(item.getEnd_time(), new SimpleDateFormat("HH:mm")));
            courseBeanList.add(bean);
        }
        return courseBeanList;
    }

}
